/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package muddb.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


/**
 *
 * @author keith
 */
@Entity
@Table( name = "mud_item_attr" )
@IdClass( MudItemAttrPK.class )
@NamedQueries( { @NamedQuery( name = "MudItemAttr.findByItemId", query =
                                                                 "SELECT m FROM MudItemAttr m WHERE m.itemId = :itemId" ),
                 @NamedQuery( name = "MudItemAttr.findByItemClassId", query =
                                                                      "SELECT m FROM MudItemAttr m WHERE m.itemClassId = :itemClassId" ),
                 @NamedQuery( name = "MudItemAttr.findByItemClassAttrId", query =
                                                                          "SELECT m FROM MudItemAttr m WHERE m.itemClassAttrId = :itemClassAttrId" ),
                 @NamedQuery( name = "MudItemAttr.findByItemAttrId", query =
                                                                     "SELECT m FROM MudItemAttr m WHERE m.itemAttrId = :itemAttrId" ),
                 @NamedQuery( name = "MudItemAttr.findByItemAttrVal", query =
                                                                      "SELECT m FROM MudItemAttr m WHERE m.itemAttrVal = :itemAttrVal" ) } )
public class MudItemAttr implements Serializable {
  private static final long serialVersionUID = 1L;
  @Id
  @Column( name = "item_id", nullable = false )
  private int itemId;
  @Id
  @Column( name = "item_class_id", nullable = false )
  private int itemClassId;
  @Id
  @Column( name = "item_class_attr_id", nullable = false )
  private int itemClassAttrId;
  @Id
  @GeneratedValue( strategy=GenerationType.SEQUENCE)
  @Column( name = "item_attr_id", nullable = false )
  private int itemAttrId;

  @Column( name = "item_attr_val", nullable=false, length=30 )
  private String itemAttrVal;
  @JoinColumns( { @JoinColumn( name = "item_id", referencedColumnName = "item_id", insertable =
                                                                                   false, updatable =
                                                                                          false ),
                  @JoinColumn( name = "item_class_id", referencedColumnName =
                                                       "item_class_id", insertable =
                                                                        false, updatable =
                                                                               false ) } )
  @ManyToOne
  private MudItem mudItem;
  @JoinColumns( { @JoinColumn( name = "item_class_id", referencedColumnName =
                                                       "item_class_id", insertable =
                                                                        false, updatable =
                                                                               false ),
                  @JoinColumn( name = "item_class_attr_id", referencedColumnName =
                                                            "item_class_attr_id", insertable =
                                                                                  false, updatable =
                                                                                         false ) } )
  @ManyToOne
  private MudItemClassAttr mudItemClassAttr;


  public MudItemAttr() {
  }


  public MudItemAttr( int itemId, int itemClassId, int itemClassAttrId, int itemAttrId ) {
    this.itemId = itemId;
    this.itemClassId = itemClassId;
    this.itemClassAttrId = itemClassAttrId;
    this.itemAttrId = itemAttrId;
  }


  public String getItemAttrVal() {
    return itemAttrVal;
  }


  public void setItemAttrVal( String itemAttrVal ) {
    this.itemAttrVal = itemAttrVal;
  }


  public MudItem getMudItem() {
    return mudItem;
  }


  public void setMudItem( MudItem mudItem ) {
    this.mudItem = mudItem;
  }


  public MudItemClassAttr getMudItemClassAttr() {
    return mudItemClassAttr;
  }


  public void setMudItemClassAttr( MudItemClassAttr mudItemClassAttr ) {
    this.mudItemClassAttr = mudItemClassAttr;
  }


  public int getItemId() {
    return itemId;
  }


  public void setItemId( int itemId ) {
    this.itemId = itemId;
  }


  public int getItemClassId() {
    return itemClassId;
  }


  public void setItemClassId( int itemClassId ) {
    this.itemClassId = itemClassId;
  }


  public int getItemClassAttrId() {
    return itemClassAttrId;
  }


  public void setItemClassAttrId( int itemClassAttrId ) {
    this.itemClassAttrId = itemClassAttrId;
  }


  public int getItemAttrId() {
    return itemAttrId;
  }


  public void setItemAttrId( int itemAttrId ) {
    this.itemAttrId = itemAttrId;
  }


  @Override
  public int hashCode() {
    int hash = 0;
    hash += (int) itemId;
    hash += (int) itemClassId;
    hash += (int) itemClassAttrId;
    hash += (int) itemAttrId;
    return hash;
  }


  @Override
  public boolean equals( Object object ) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if ( !( object instanceof MudItemAttr ) ) {
      return false;
    }
    MudItemAttr other = (MudItemAttr) object;
    if ( this.itemId != other.itemId ) {
      return false;
    }
    if ( this.itemClassId != other.itemClassId ) {
      return false;
    }
    if ( this.itemClassAttrId != other.itemClassAttrId ) {
      return false;
    }
    if ( this.itemAttrId != other.itemAttrId ) {
      return false;
    }
    return true;
  }


  @Override
  public String toString() {
    return "muddb.entities.MudItemAttr[itemId=" + itemId + ", itemClassId=" + itemClassId + ", itemClassAttrId=" + itemClassAttrId + ", itemAttrId=" + itemAttrId + "]";
  }

}
